<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${drug?.id} == null ? '添加药品' : '编辑药品'">药品信息</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <style>
        body {
            background-color: #f9fafb;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        .form-container {
            max-width: 600px;
            margin: 3rem auto;
            padding: 2rem;
            background-color: white;
            border-radius: 0.75rem;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }

        .form-label {
            font-weight: 600;
            color: #1f2937;
        }

        .btn-submit {
            background-color: #3b82f6;
            border-color: #3b82f6;
            transition: all 0.3s ease;
        }

        .btn-submit:hover {
            background-color: #2563eb;
            transform: translateY(-2px);
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body>

<div class="form-container">
    <h3 class="mb-4" th:text="${drug != null ? (drug.id == null ? '添加药品' : '编辑药品') : '添加药品'}">
        药品信息</h3>
    <form th:action="@{/admin/drug/save}" method="post" th:object="${drug}">
        <input type="hidden" th:field="*{id}" />

        <div class="mb-3">
            <label for="name" class="form-label">药品名称</label>
            <input type="text" id="name" th:field="*{name}" class="form-control" required />
        </div>

        <div class="mb-3">
            <label for="specification" class="form-label">规格</label>
            <input type="text" id="specification" th:field="*{specification}" class="form-control" />
        </div>

        <div class="mb-3">
            <label for="manufacturer" class="form-label">生产厂家</label>
            <input type="text" id="manufacturer" th:field="*{manufacturer}" class="form-control" />
        </div>

        <div class="mb-3">
            <label for="stock" class="form-label">库存数量</label>
            <input type="number" id="stock" th:field="*{stock}" class="form-control" min="0" />
        </div>

        <div class="mb-3">
            <label for="price" class="form-label">单价 (元)</label>
            <input type="number" step="0.01" min="0" id="price" th:field="*{price}" class="form-control" />
        </div>

        <div class="mb-3">
            <label for="stockInDate" class="form-label">药品入库时间</label>
            <input type="datetime-local" id="stockInDate" th:field="*{stockInDate}" class="form-control" />
        </div>

        <div class="mb-3">
            <label for="validUntil" class="form-label">有效期至</label>
            <input type="date" id="validUntil" th:field="*{validUntil}" class="form-control" />
        </div>

        <button type="submit" class="btn btn-submit w-100 mt-3"
                th:text="${drug.id == null ? '添加药品' :  '更新药品'}">保存</button>
    </form>

    <a th:href="@{/admin/drug/list}" class="btn btn-outline-secondary w-100 mt-3">返回列表</a>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
